<?php
function dtd($dtd = 'strict') {
	switch($dtd) {
		case 'strict':
			$html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
			break;
		default:break;
	}
	$html .='
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn" xml:
lang="zh-cn">';
	return $html;
}

function meta($charset = 'utf-8') {
	return '
<meta http-equiv="Content-type" content="text/html; charset='.$charset.'" />';
}

function head() {
	$html[] = dtd();
	$html[] = "\r\n<head>";
	$html[] = meta();
	$html[] = "\r\n<title>Test</title>";
	$html[] = "\r\n</head>";
	return implode("",$html);
}

function body($htmlcode = '') {
	$html[] = "\r\n<body>";
	$html[] = $htmlcode;
	$html[] = "\r\n</body></html>";
	return implode("",$html);
}

function c_header() {
	return "\r\n<div id=\"header\">
	<div id=\"topnav\"></div>
	<div id=\"menu\">
		
	</div>
</div>";
}

function c_footer() {
	return "\r\n<div id=\"footer\">\r\n</div>";
}



function db_connect($dbconfig) {
	//var_dump($dbconfig);
	$dsn = "mysql:dbname=".$dbconfig['schema'].";host=localhost";
	$user = $dbconfig['user'];
	$pass = $dbconfig['pass'];
	try {
		return new PDO($dsn, $user, $pass);
	} catch (PDOException $e) {
		return 'Connection failed: ' . $e->getMessage();
	}
}

?>